package com.heima.wemedia.controller.v1;

import com.heima.model.common.dtos.ResponseResult;
import com.heima.model.wemedia.dtos.WeNewsAuditPageDto;
import com.heima.model.wemedia.dtos.WmNewsAuditUpdateDto;
import com.heima.model.wemedia.dtos.WmNewsDto;
import com.heima.model.wemedia.dtos.WmNewsPageReqDto;
import com.heima.model.wemedia.pojos.WmNews;
import com.heima.wemedia.service.WmNewsService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

@RestController
@RequestMapping("/api/v1/news")
public class NewsController {
    @Autowired
    private WmNewsService wmNewsService;


    @PostMapping("/list")
    public ResponseResult findList(@RequestBody WmNewsPageReqDto dto){
        return wmNewsService.findList(dto);
    }

    @PostMapping("/submit")
    public ResponseResult submit(@RequestBody WmNewsDto wmNewsDto){
        return wmNewsService.submit(wmNewsDto);
    }

    @GetMapping("/one/{id}")
    public ResponseResult findOne(@PathVariable Integer id){
        return wmNewsService.findOne(id);
    }

    @GetMapping("/del_news/{id}")
    public ResponseResult deleteOne(@PathVariable Integer id){
        return wmNewsService.deleteOne(id);
    }

    @PostMapping("/down_or_up")
    public ResponseResult downOrUp(@RequestBody WmNewsDto wmNewsDto){
        return wmNewsService.downOrUp(wmNewsDto);
    }

    @PostMapping("/list_vo")
    public ResponseResult auditList(@RequestBody WeNewsAuditPageDto dto){
        return wmNewsService.auditList(dto);
    }

    @GetMapping("/one_vo/{id}")
    public ResponseResult auditDetail(@PathVariable Integer id){
        return wmNewsService.auditDetail(id);
    }

    @PostMapping("/auth_pass")
    public ResponseResult authPass(@RequestBody WmNewsAuditUpdateDto dto){
        return wmNewsService.authUpdate(dto);
    }

    @PostMapping("/auth_fail")
    public ResponseResult authFail(@RequestBody WmNewsAuditUpdateDto dto){
        return wmNewsService.authUpdate(dto);
    }

}
